package com.design.interpreter;

/**
 * @author leali
 * @title: CommandNode
 * @projectName design
 * @description: 语句命令节点类：非终结符表达式
 * @date 2022/1/3 19:00
 */
public class CommandNode extends Node {
    private Node node;
    @Override
    public void interpret(Context context) {
        //处理LOOP循环命令
        if ("LOOP".equals(context.currentToken())) {
            node = new LoopCommandNode();
            node.interpret(context);
        }
        //处理其他基本命令
        else {
            node = new PrimitiveCommandNode();
            node.interpret(context);
        }
    }

    @Override
    public void execute() {
        node.execute();
    }
}
